package com.demo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo.common.kit.BeanUtils;
import com.demo.common.page.PagedResult;
import com.demo.dao.SysUserMapper;
import com.demo.model.SysUser;
import com.demo.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	SysUserMapper userMapper;

	@Override
	public SysUser getByUsernames(String username) {
		return userMapper.selectByUsername(username);
	}

	@Override
	public PagedResult<SysUser> findUserList(Integer pageNumber, Integer pageSize) {
		pageNumber = pageNumber == null ? 1 : pageNumber;
		pageSize = pageSize == null ? 10 : pageSize;
		PageHelper.startPage(pageNumber, pageSize);
		return BeanUtils.toPagedResult(userMapper.findUserList());
	}

}
